import 'package:guochaoapp/model/spu_entity.dart';

spuEntityFromJson(SpuEntity data, Map<String, dynamic> json) {
	if (json['success'] != null) {
		data.success = json['success'];
	}
	if (json['msg'] != null) {
		data.msg = json['msg'].toString();
	}
	if (json['code'] != null) {
		data.code = json['code'] is String
				? int.tryParse(json['code'])
				: json['code'].toInt();
	}
	if (json['data'] != null) {
		data.data = new SpuData().fromJson(json['data']);
	}
	if (json['sign'] != null) {
		data.sign = json['sign'];
	}
	return data;
}

Map<String, dynamic> spuEntityToJson(SpuEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['success'] = entity.success;
	data['msg'] = entity.msg;
	data['code'] = entity.code;
	if (entity.data != null) {
		data['data'] = entity.data.toJson();
	}
	data['sign'] = entity.sign;
	return data;
}

spuDataFromJson(SpuData data, Map<String, dynamic> json) {
	if (json['spuList'] != null) {
		data.spuList = new List<SpuDataSpuList>();
		(json['spuList'] as List).forEach((v) {
			data.spuList.add(new SpuDataSpuList().fromJson(v));
		});
	}
	return data;
}

Map<String, dynamic> spuDataToJson(SpuData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	if (entity.spuList != null) {
		data['spuList'] =  entity.spuList.map((v) => v.toJson()).toList();
	}
	return data;
}

spuDataSpuListFromJson(SpuDataSpuList data, Map<String, dynamic> json) {
	if (json['spuId'] != null) {
		data.spuId = json['spuId'] is String
				? int.tryParse(json['spuId'])
				: json['spuId'].toInt();
	}
	if (json['mallLogo'] != null) {
		data.mallLogo = json['mallLogo'].toString();
	}
	if (json['mallTitle'] != null) {
		data.mallTitle = json['mallTitle'].toString();
	}
	if (json['brandId'] != null) {
		data.brandId = json['brandId'] is String
				? int.tryParse(json['brandId'])
				: json['brandId'].toInt();
	}
	if (json['brandName'] != null) {
		data.brandName = json['brandName'].toString();
	}
	if (json['spuSpec'] != null) {
		data.spuSpec = json['spuSpec'].toString();
	}
	if (json['canSell'] != null) {
		data.canSell = json['canSell'];
	}
	return data;
}

Map<String, dynamic> spuDataSpuListToJson(SpuDataSpuList entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['spuId'] = entity.spuId;
	data['mallLogo'] = entity.mallLogo;
	data['mallTitle'] = entity.mallTitle;
	data['brandId'] = entity.brandId;
	data['brandName'] = entity.brandName;
	data['spuSpec'] = entity.spuSpec;
	data['canSell'] = entity.canSell;
	return data;
}